//
//  UIWebView+Conform.m
//  packetwallet
//
//  Created by 张冬 on 15/10/21.
//  Copyright © 2015年 Hangzhou TaiXuan Network Technology Co., Ltd. All rights reserved.
//

#import "UIWebView+Conform.h"

@implementation UIWebView (Conform)

- (NSURL *)URL {
    return [[self request] URL];
}

- (NSString *)title {
    return [self stringByEvaluatingJavaScriptFromString:@"document.title"];
}

- (UIView *)baseView {
    return self;
}

- (void)scalesPageToFit:(BOOL)isFit {
    self.scalesPageToFit = isFit;
}

- (void)loadReuqestWithString:(NSString *)string {
    SEL selector = NSSelectorFromString(@"loadRequest:");
    if ([self respondsToSelector:selector]) {
        
        [self performSelectorOnMainThread:selector withObject:[NSURLRequest requestWithURL:[NSURL URLWithString:string]] waitUntilDone:YES];
    }
}

- (void)clearCacheIfNeed {
    [[NSURLCache sharedURLCache] removeAllCachedResponses];
}

#pragma mark UIWebViewDelegate
- (void)setWebViewDelegate:(id <UIWebViewDelegate>)delegate {
    self.delegate = delegate;
}

@end
